From e3a4b98ceb25bcbdddf387e71960190bdea162fd Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 19 May 2009 16:08:53 +0000 Subject: [PATCH] Followup to 50635: Consolidate all of these hacky global checks into a clean method. Also move a global and document it. --- includes/specials/SpecialBlockip.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index 5c15fee2ed..00c2e18f9d 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -62,7 +62,7 @@ class IPBlockForm { $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault ); $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault ); $this->BlockEmail = false; - if( $wgEnableUserEmail && $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) { + if( self::canBlockEmail( $wgUser ) ) { $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false ); } $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false ); @@ -233,8 +233,7 @@ class IPBlockForm { " ); - global $wgSysopEmailBans, $wgBlockAllowsUTEdit, $wgEnableUserEmail; - if( $wgEnableUserEmail && $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) { + if( self::canBlockEmail( $wgUser ) ) { $wgOut->addHTML("   @@ -272,6 +271,9 @@ class IPBlockForm { " ); + + # Can we explicitly disallow the use of user_talk? + global $wgBlockAllowsUTEdit; if( $wgBlockAllowsUTEdit ){ $wgOut->addHTML(" @@ -311,6 +313,16 @@ class IPBlockForm { $this->showLogFragment( $wgOut, Title::makeTitle( NS_USER, $this->BlockAddress ) ); } } + + /** + * Can we do an email block? + * @param User $user The sysop wanting to make a block + * @return boolean + */ + protected function canBlockEmail( $user ) { + global $wgEnableUserEmail, $wgSysopEmailBans; + return ($wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' )); + } /** * Backend block code. -- 2.20.1